
package com.bot.nft.module.dc.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bot.common.pojo.CommonResult;
import com.bot.nft.module.dc.domain.bo.DcAuthorInfoBo;
import com.bot.nft.module.dc.domain.vo.AuthorQueryVo;
import com.bot.nft.module.dc.domain.vo.DcAuthorInfoVo;
import com.bot.nft.module.dc.service.DcAuthorInfoService;
import io.minio.MinioClient;
import io.minio.ObjectWriteResponse;
import io.minio.PutObjectArgs;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
 * dc_author_info控制器
 *
 * @author lumengli
 * @date  2024/01/24 15:57
 */

@RestController
@RequestMapping("/dc")
public class DcAuthorInfoController {

    @Resource
    private DcAuthorInfoService dcAuthorInfoService;
    /**
     * 添加创作者
     *
     * @param dcAuthorInfoBo
     * @return
     */
    @PostMapping("/addAuthor.do")
    private CommonResult<Boolean> addAuthorDcInfo(@RequestBody DcAuthorInfoBo dcAuthorInfoBo) {

        Boolean addAuthorDcInfo = dcAuthorInfoService.addAuthorDcInfo(dcAuthorInfoBo);
        if (!addAuthorDcInfo) {
            return CommonResult.error();

        }
        return CommonResult.ok("添加成功");
    }

    /**
     * 禁用创作者
     *
     * @param id
     * @return
     */
    @GetMapping("/{id}/disAuthor.do")
    private CommonResult<Boolean> disAuthorDcInfo(@PathVariable("id") String id) {

        Boolean disAuthorDcInfo = dcAuthorInfoService.disAuthorDcInfo(id);
        if (!disAuthorDcInfo) {
            return CommonResult.error();
        }

        return CommonResult.ok();

    }

    /**
     * 分页查询创作者
     *
     * @param authorQueryBo
     * @param pageNo
     * @param pageSize
     * @return
     */
    @PostMapping("/{pageNo}/{pageSize}/listAuthor.do")
    private CommonResult<Page<DcAuthorInfoVo>> queryAuthorByPage(@RequestBody AuthorQueryVo authorQueryBo, @PathVariable("pageNo") Integer pageNo, @PathVariable("pageSize") Integer pageSize) {

        Page<DcAuthorInfoVo> page = dcAuthorInfoService.page(authorQueryBo.getKeyword(), authorQueryBo.getStatus(), pageNo, pageSize);
        return CommonResult.data(page);
    }

    /**
     * 查看创作者
     *
     * @param id
     * @return
     */
    @GetMapping("/{id}/getAuthor.do")
    private CommonResult<DcAuthorInfoVo> getAuthorDcInfo(@PathVariable("id") String id) {

        DcAuthorInfoVo authorDcInfo = dcAuthorInfoService.getAuthorDcInfo(id);
        return CommonResult.data(authorDcInfo);

    }

    /**
     * 删除创作者
     *
     * @param id
     * @return
     */
    @GetMapping ("/{id}/delAuthor.do")
    private CommonResult<Boolean> delAuthorDcInfo(@PathVariable("id") String id) {

        Boolean delAuthorDcInfo = dcAuthorInfoService.delAuthorDcInfo(id);
        if (!delAuthorDcInfo) {
            return CommonResult.error();
        }

        return CommonResult.ok();
    }

    /**
     * 修改创作者
     *
     * @param dcAuthorInfoBo
     * @return
     */
    @PostMapping("/editAuthor.do")
    private CommonResult<Boolean> updateAuthorDcInfo(@RequestBody DcAuthorInfoBo dcAuthorInfoBo) {

        Boolean updateAuthorDcInfo = dcAuthorInfoService.updateAuthorDcInfo(dcAuthorInfoBo);
        if (!updateAuthorDcInfo) {
            return CommonResult.error();
        }

        return CommonResult.ok();

    }

    /**
     * 启用创作者
     *
     * @param id
     * @return
     */
    @GetMapping("/{id}/startAuthor.do")
    private CommonResult<Boolean> startAuthorDcInfo(@PathVariable("id") String id) {

        Boolean startAuthorDcInfo = dcAuthorInfoService.startAuthorDcInfo(id);
        if (!startAuthorDcInfo) {
            return CommonResult.error();
        }

        return CommonResult.ok();

    }



}
